import * as api from '../util/api'
export default{
    namespace:"info",
    state:{
        token:''
    },
    effects:{
        *getData(payload,{call,put}){
            console.log(payload)
            const result = yield call(api.adminLogin,payload.payload)
            console.log(result)
            if (result.status === 200) {
                // if (callback && typeof callback === 'function') {
                //   callback(response); // 返回结果
                // }
                console.log('yes')
                yield put({
                type:'change',
                payload:{
                  token:result.data.token
                }
            })
            const token = result.data.token
            window.localStorage.setItem('token', token)
             location.href = '/show'
              } else {
               console.log('error')
              }
            
        }
    }
}